/**
 * 
 */
package com.yixun.qfbao.hander;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.yixun.qfbao.api.service.EstateAdviserService;
import com.yixun.qfbao.apidto.BatchAddEstateAdviserResDto;
import com.yixun.qfbao.dto.base.BaseRequestDTO;
import com.yixun.qfbao.dto.base.BaseResponseDTO;
import com.yixun.qfbao.hander.base.CommonAbstractHander;
import com.yixun.qfbao.vo.BatchAddEstateAdviserReqVo;
import com.yixun.qfbao.xf.model.enums.ResultEnum;

/**
 * @author yuefei.chen
 *
 */
@Service
public class BatchAddEstateAdviserHander extends CommonAbstractHander {
	
	private static Logger logger=LoggerFactory.getLogger(BatchAddEstateAdviserHander.class);

	@Autowired
	private EstateAdviserService estateAdviserService;
	
	/* (non-Javadoc)
	 * @see com.yixun.qfbao.hander.base.CommonAbstractHander#doBusiness(com.yixun.qfbao.dto.base.BaseRequestDTO)
	 */
	@SuppressWarnings("rawtypes")
	@Override
	public BaseResponseDTO doBusiness(BaseRequestDTO reqDto) {
		
		BatchAddEstateAdviserReqVo req = (BatchAddEstateAdviserReqVo)reqDto;
		BaseResponseDTO<String> res = new BaseResponseDTO<>();
		BatchAddEstateAdviserResDto resDto=new BatchAddEstateAdviserResDto();
		try {
			resDto = estateAdviserService.batchAddEstateAdviser(req.getParams());
		} catch (Exception e) {
			logger.error("handler batch add estate adviser error: {}",e);
			resDto.setResult(ResultEnum.FAIL.getNo());
			resDto.setResultMsg("批量插入置业顾问失败！");
		}
		res.setResult(resDto.getResult());
		if(res.getResult().equals(ResultEnum.SUCCESS.getNo())) {
			res.setResData("success");
		}else {
			res.setResData("failure");
		}
		return res;
	}

}
